package school.action;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import school.service.ISchoolService;
import base.common.BaseAction;
import base.common.PageView;
import entity.Department;
import entity.User;

public class SchoolDetailFindAction  extends BaseAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
    ISchoolService schoolService;
    
    @Resource(name="department")
    Department school;
    
    @Resource(name="user")
    User loginUser;
	@SuppressWarnings("unchecked")
	public String schoolDetail(){
		Map<String, Object> param=this.getMap();
		loginUser=(User) this.getSession().get("loginUser");
		param.put("level",loginUser.getUserType().getId());
		List<Department> list=new ArrayList<Department>();
		list= (List<Department>) schoolService.findPart(Department.class, currentPage,
				PAGE_SIZE, "id", "ASC", param);
		put("pageView", new PageView<Department>(currentPage, PAGE_SIZE, 1, list));
		if(list.size()>0){
			school=list.get(0);
			this.getSession().put("department", school);
		}
		
		if(school!=null){
		return SUCCESS;
		}
		return LOGIN;
	}
	
	public String edit(){
		
		return "edit";
		
	}
	public ISchoolService getSchoolService() {
		return schoolService;
	}
	public void setSchoolService(ISchoolService schoolService) {
		this.schoolService = schoolService;
	}
	public Department getDepartment() {
		return school;
	}
	public void setDepartment(Department department) {
		this.school = department;
	}
	public Department getSchool() {
		return school;
	}
	public void setSchool(Department school) {
		this.school = school;
	}
	public User getLoginUser() {
		return loginUser;
	}
	public void setLoginUser(User loginUser) {
		this.loginUser = loginUser;
	}

	
}
